<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	Map<String,Object> map = new HashMap<String,Object>();
	map = request.getAttribute("map") != null?(Map) request.getAttribute("map"):null;
	int rownum = request.getAttribute("rownum") == null?10:(Integer) request.getAttribute("rownum");
	int start = (Integer) request.getAttribute("start");
	int total = 0;
	int listsize = 0;
	int allpage = 0;
	int nowpage = 1;
	if(map != null)
	{
		total = (Integer) map.get("total");
		listsize = (Integer) map.get("listsize");
		allpage = total % rownum == 0?total / rownum:total / rownum + 1;
	}
	if(start != 0)
	{
		nowpage += start / rownum;
	}
%>
<div class="search_result">
<%-- 
数组顺序  结果集数组对应的字段在和传入的顺序一样，在service层设置
            0          1          2         3          4   
fileds = {"id","articleclass","title","summary","content"};--%>
	<%
		for(int i = 0;i < listsize;i++)
		{
			String[] fileds = (String[])map.get("list" + i);
			%>
			<div class="title">
			 <a href="<%=request.getContextPath() %>/Article?id=<%=fileds[0] %>" target="_blank"><%=fileds[2] %></a>
			</div>
			<div class="abstract">
			  ⊙摘要:<%=fileds[3] %>
			</div>
			<div class="searchcnt">
			<%=fileds[4] %>
			</div>
			<%}%>
</div>
<%--以下是分页部分 --%>
<div class="search_page">
<hr>
	<input type="hidden" id="start" value="<%=start%>" />
	找到约<%=total + "条结果"%>
	<%=nowpage != 1?"<span style='cursor: pointer;' onclick=\"upordownpage('u')\">上一页</span>":""%>
	<%
		if(nowpage - 5 <= 0)
		{
			for(int i = 1;i <=(allpage<=10?allpage:10);i++)
			{
			   if(i==nowpage){
				 out.print("<span style='padding:5px;font-size:15px;color:red;'>"+i + "</span>");
				}else{
				 out.print("<span style='cursor: pointer;padding:5px;font-size:15px;' onclick='topage("+i+");'>["+i + "]</span>");
				}
			}
		}else if(nowpage + 5 >= allpage)
		{
			if(allpage-9>0){
				for(int i = allpage-9;i<allpage+1;i++)
				{
					if(i==nowpage){
					 out.print("<span style='padding:5px;font-size:15px;color:red;'>"+i + "</span>");
					}else{
					 out.print("<span style='cursor: pointer;padding:5px;font-size:15px;' onclick='topage("+i+");'>["+i + "]</span>");
					}
				}	
				
			}else{
			  for(int i = nowpage-5;i<allpage+1;i++)
			  {
				if(i==nowpage){
				 out.print("<span style='padding:5px;font-size:15px;color:red;'>"+i + "</span>");
				}else{
				 out.print("<span style='cursor: pointer;padding:5px;font-size:15px;' onclick='topage("+i+");'>["+i + "]</span>");
				}
			  }
			}
			
		}else
		{
			for(int i = nowpage - 5;i < nowpage + 5;i++)
			{
				if(i==nowpage){
				 out.print("<span style='padding:5px;font-size:15px;color:red;'>"+i + "</span>");
				}else{
				 out.print("<span style='cursor: pointer;padding:5px;font-size:15px;' onclick='topage("+i+");'>["+i + "]</span>");
				}
			}

		}
	%>
	<%=allpage != nowpage && total != 0?"<span style='cursor: pointer;' onclick=\"upordownpage('d')\">下一页</span>":""%>
</div>